package jianzhiOfferII;
//剑指 Offer II 009. 乘积小于 K 的子数组
public class Num009_numSubarrayProductLessThanK {
    public int numSubarrayProductLessThanK(int[] nums, int k) {
        int sum = 1;
        int start = 0;
        int count = 0;
        for (int i = 0; i < nums.length; i++) {
            sum *= nums[i];
            while ( start <= i && sum  >= k){
                sum /= nums[start];
                start++;
            }
                count += i - start + 1;
        }
        return count;
    }
}
